package com.xbongbong.paas.service;

import com.alibaba.fastjson.JSONArray;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import org.apache.poi.ss.usermodel.Workbook;

import java.util.List;
import java.util.Map;

/**
 * Excel操作service
 *
 * @author wufeng
 * @date 2018/9/25 10:13
 */
public interface ExcelOperatorService {

    /**
     * 下载生成Excel模板
     * @param businessType 业务类型
     * @param dataExplain 表单解释
     * @param name        表单名称
     * @param excelType    excel类型（见DownloadExcelTypeEnum）
     * @param dataRowNum
     * @return Workbook
     */
    Workbook createExcelTemplate(Integer businessType, JSONArray dataExplain, String name,int excelType, int dataRowNum,boolean isFileImport);

    /**
     * 导出生成Excel数据
     *
     * @param formDataList     导出的数据
     * @param explainJsonArray 表单解释
     * @param name             表单名称
     * @return Workbook
     */
    Workbook createExcel(List<PaasFormDataEntityExt> formDataList, JSONArray explainJsonArray, String name, FormDataListDTO formDataListDTO) throws XbbException;

    /**
     * 生成导入模版方法
     *
     * @param width         列宽
     * @param sheetName     sheet的名字
     * @param colTitle      标题
     * @param moreTitleList 标题行，类型为：List<List<Map<String,Object>>>，如果有多行，则塞入多个List<Map<String,Object>>
     * @return Workbook
     * @author chy
     */
    Workbook createEmptyExcel4MoreTitle(int width, String sheetName, String[] colTitle, List<List<Map<String, Object>>> moreTitleList);

    /**
     * 导出对账单excel，包含表头
     * @param sheetName
     * @param titleList
     * @param level
     * @return
     */
    Workbook createStatementExcelWithHead(String sheetName, List<List<List<Object>>> titleList, int level);

    /**
     * 拼装创建Excel
     * @param workbook
     * @param formDataList
     * @param explainJsonArray
     * @param name
     * @param formDataListDTO
     * @throws XbbException
     * @return
     */
    Workbook createExcel(Workbook workbook, List<PaasFormDataEntityExt> formDataList, JSONArray explainJsonArray, String name, FormDataListDTO formDataListDTO) throws XbbException;
}
